Ipynb widget parity - #742
Merged
Merged
Conversation
…d RadioButtons Widget-parity gaps with the Qt backend, each mapped onto the natural ipywidgets equivalent: - RangeSlider/FloatRangeSlider -> IntRangeSlider/FloatRangeSlider - ProgressBar -> FloatProgress (no step trait, so step is tracked on the backend widget; the frontend ProgressBar manages step itself) - Image -> ipywidgets.Image, encoding the RGBA array to PNG via PIL (the magicgui[image] extra, same as the frontend widget requires) - RadioButtons -> ipywidgets.RadioButtons (vertical only for now; horizontal raises NotImplementedError) The single-RadioButton -> ipywidgets.RadioButtons mapping is left untouched (pre-existing semantic mismatch, needs its own discussion). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
_mgui_start_timer/_mgui_stop_timer are implemented with asyncio.call_later on the kernel's running event loop, matching the Qt backend's single-app-timer semantics (including single-shot). _mgui_process_events becomes a no-op instead of raising: ipywidgets updates are pushed over the kernel's comm channels as traits change, so there is nothing to flush synchronously. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #742 +/- ##
==========================================
+ Coverage 89.32% 89.50% +0.17%
==========================================
Files 40 40
Lines 4835 4879 +44
==========================================
+ Hits 4319 4367 +48
+ Misses 516 512 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
larsoner
added a commit
to larsoner/magicgui
that referenced
this pull request
Aug 24, 2026
The namespace from runpy.run_path is discarded, so widgets created by
an example are garbage-collected at an arbitrary later point during
event processing. A still-visible widget whose C++ side is deleted
mid-event-loop can receive a paintEvent during deletion, which PyQt5
escalates to a process abort:
RuntimeError: wrapped C/C++ object of type QRangeSlider has been
deleted
as seen intermittently on the windows-latest (3.12) pyqt5 job in
test_example[demo_widgets/range_slider.py] (e.g. the scheduled main
run on 2026-08-22, and both pyapp-kit#741 and pyapp-kit#742).
Close (hide) all top-level widgets first so nothing can paint, then
deleteLater() + sendPostedEvents(None, DeferredDelete) to destroy the
native widgets (and stop their timers) while hidden -- note that
processEvents() alone does NOT dispatch DeferredDelete events -- then
gc.collect() for anything left over.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tlambert03
pushed a commit
to larsoner/magicgui
that referenced
this pull request
Aug 26, 2026
The namespace from runpy.run_path is discarded, so widgets created by
an example are garbage-collected at an arbitrary later point during
event processing. A still-visible widget whose C++ side is deleted
mid-event-loop can receive a paintEvent during deletion, which PyQt5
escalates to a process abort:
RuntimeError: wrapped C/C++ object of type QRangeSlider has been
deleted
as seen intermittently on the windows-latest (3.12) pyqt5 job in
test_example[demo_widgets/range_slider.py] (e.g. the scheduled main
run on 2026-08-22, and both pyapp-kit#741 and pyapp-kit#742).
Close (hide) all top-level widgets first so nothing can paint, then
deleteLater() + sendPostedEvents(None, DeferredDelete) to destroy the
native widgets (and stop their timers) while hidden -- note that
processEvents() alone does NOT dispatch DeferredDelete events -- then
gc.collect() for anything left over.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tlambert03
pushed a commit
that referenced
this pull request
Aug 26, 2026
* test: deterministically tear down example widgets
The namespace from runpy.run_path is discarded, so widgets created by
an example are garbage-collected at an arbitrary later point during
event processing. A still-visible widget whose C++ side is deleted
mid-event-loop can receive a paintEvent during deletion, which PyQt5
escalates to a process abort:
RuntimeError: wrapped C/C++ object of type QRangeSlider has been
deleted
as seen intermittently on the windows-latest (3.12) pyqt5 job in
test_example[demo_widgets/range_slider.py] (e.g. the scheduled main
run on 2026-08-22, and both #741 and #742).
Close (hide) all top-level widgets first so nothing can paint, then
deleteLater() + sendPostedEvents(None, DeferredDelete) to destroy the
native widgets (and stop their timers) while hidden -- note that
processEvents() alone does NOT dispatch DeferredDelete events -- then
gc.collect() for anything left over.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* test: allow pytest-qt >=4.5 everywhere except PySide2
pytest-qt 4.4.0 is incompatible with recent PySide6: qtbot.waitSignal
fails with 'SystemError: <method disconnect of SignalInstance> returned
a result with an exception set' and a TimeoutError in
test_parent_changed (reproduced locally with PySide6 6.11.2 +
pytest-qt 4.4.0; fixed by pytest-qt 4.5.0, see pytest-dev/pytest-qt#552).
This is what has been failing every pyside6 CI job (and the scheduled
runs on main) since at least mid-July.
pytest-qt 4.5 dropped PySide2, so the pyside2 dependency group keeps
the 4.4.0 pin via a separate test-qt-legacy group, declared as a uv
conflict so universal resolution still succeeds.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* build: emit core metadata 2.4 until twine accepts 2.5
hatchling 1.32.0 (2026-08-11) bumped the default core metadata version
to 2.5, which the twine run by build-and-inspect-python-package rejects
('InvalidDistribution: 2.5 is not a valid metadata version'). Nobody
noticed because build-and-inspect needs the test job, which has been
red since mid-July (see previous commit). Verified locally: with this
setting both the wheel and sdist emit Metadata-Version 2.4 and pass
'twine check --strict'.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* style(pre-commit.ci): auto fixes [...]
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Member
|
thanks! Simple enough! |
tlambert03
added a commit
that referenced
this pull request
Aug 26, 2026
* fix: handle PEP 604 unions (`X | Y`) like `Union[X, Y]`
`get_origin(int | None)` is `types.UnionType`, not `typing.Union`, on
python < 3.14 -- so the four `get_origin(...) is Union` comparisons
silently took the non-union path for PEP 604 annotations.
Most visibly, the Optional wrapper was not stripped from a widget's
reported annotation:
@magicgui
def f(x: Optional[int] = None): ... # .annotation -> int
@magicgui
def f(x: int | None = None): ... # .annotation -> int | None
and `register_type(int | str, return_callback=...)` registered nothing
for the individual member types.
Adds `magicgui._util.is_union`, which accepts both spellings, and uses
it at all four sites.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* style: import Callable from collections.abc in the ipynb backend
UP035 under the new py311 target. #742 merged after #745 switched
target-version, so its CI ran against the old config and main is
currently failing ruff.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* style: enable UP045 for source now that PEP 604 unions work
The preceding fix makes `X | None` behave like `Optional[X]`, so the
pyupgrade rewrite is safe for src. Scoped deliberately:
- UP045 is enabled for src/ and docs/ only; tests/ keep it ignored,
since they exercise both spellings on purpose (see test_no_order).
- UP007 stays ignored: `Union` is still needed as a runtime *value* for
the public type aliases (PathLike, ChoicesType, AppRef, TableData,
WidgetRef) and for `Union[args]` construction. ruff offers no fix for
those 11 sites, so enabling it would just leave permanent errors.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
More notebook parity work with Fable 5 (reviewed by me):
asyncio.call_later